<?php

/**
 * This is the model class for table "livsmedel".
 *
 * The followings are the available columns in table 'livsmedel':
 * @property integer $livsmedelsID
 * @property string $livsmedelsnamn
 * @property string $kj
 * @property string $kcal
 * @property string $protein
 * @property string $fett
 * @property string $kolhydrater
 * @property string $fibrer
 * @property string $salt
 * @property string $aska
 * @property string $vatten
 * @property string $alkohol
 * @property string $monosackarider
 * @property string $disackarider
 * @property string $sackaros
 * @property string $fullkorn_totalt
 * @property string $summa_mattade_fettsyror
 * @property string $summa_enkelomattade_fettsyror
 * @property string $summa_fleromattade_fettsyror
 * @property string $fettsyra
 * @property string $ePA
 * @property string $dPA
 * @property string $dHA
 * @property string $summa_transfettsyror
 * @property string $kolesterol
 * @property string $retinolekvivalenter
 * @property string $retinol
 * @property string $vitamin_D
 * @property string $vitamin_E
 * @property string $vitamin_K
 * @property string $tiamin
 * @property string $riboflavin
 * @property string $vitamin_C
 * @property string $niacin
 * @property string $niacinekvivalenter
 * @property string $vitamin_B6
 * @property string $vitamin_B12
 * @property string $fosfor
 * @property string $folat
 * @property string $jod
 * @property string $jarn
 * @property string $kalcium
 * @property string $kalium
 * @property string $magnesium
 * @property string $natrium
 * @property string $selen
 * @property string $zink
 */
class Livsmedel extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Livsmedel the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'livsmedel';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
		array('livsmedelsnamn, kj, kcal, protein, fett, kolhydrater, fibrer, salt, aska, vatten, alkohol, monosackarider, disackarider, sackaros, fullkorn_totalt, summa_mattade_fettsyror, summa_enkelomattade_fettsyror, summa_fleromattade_fettsyror, fettsyra, ePA, dPA, dHA, summa_transfettsyror, kolesterol, retinolekvivalenter, retinol, vitamin_D, vitamin_E, vitamin_K, tiamin, riboflavin, vitamin_C, niacin, niacinekvivalenter, vitamin_B6, vitamin_B12, fosfor, folat, jod, jarn, kalcium, kalium, magnesium, natrium, selen, zink', 'required'),
		array('livsmedelsnamn', 'length', 'max'=>100),
		array('kj, kcal, protein, fett, kolhydrater, fibrer, salt, aska, vatten, alkohol, monosackarider, disackarider, sackaros, fullkorn_totalt, summa_mattade_fettsyror, summa_enkelomattade_fettsyror, summa_fleromattade_fettsyror, fettsyra, ePA, dPA, dHA, summa_transfettsyror, kolesterol, retinolekvivalenter, retinol, vitamin_D, vitamin_E, vitamin_K, tiamin, riboflavin, vitamin_C, niacin, niacinekvivalenter, vitamin_B6, vitamin_B12, fosfor, folat, jod, jarn, kalcium, kalium, magnesium, natrium, selen, zink', 'length', 'max'=>6),
		// The following rule is used by search().
		// Please remove those attributes that should not be searched.
		array('livsmedelsID, livsmedelsnamn, kj, kcal, protein, fett, kolhydrater, fibrer, salt, aska, vatten, alkohol, monosackarider, disackarider, sackaros, fullkorn_totalt, summa_mattade_fettsyror, summa_enkelomattade_fettsyror, summa_fleromattade_fettsyror, fettsyra, ePA, dPA, dHA, summa_transfettsyror, kolesterol, retinolekvivalenter, retinol, vitamin_D, vitamin_E, vitamin_K, tiamin, riboflavin, vitamin_C, niacin, niacinekvivalenter, vitamin_B6, vitamin_B12, fosfor, folat, jod, jarn, kalcium, kalium, magnesium, natrium, selen, zink', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'livsmedelsID' => 'Livsmedels',
			'livsmedelsnamn' => 'Livsmedelsnamn',
			'kj' => 'Kj',
			'kcal' => 'Kcal',
			'protein' => 'Protein',
			'fett' => 'Fett',
			'kolhydrater' => 'Kolhydrater',
			'fibrer' => 'Fibrer',
			'salt' => 'Salt',
			'aska' => 'Aska',
			'vatten' => 'Vatten',
			'alkohol' => 'Alkohol',
			'monosackarider' => 'Monosackarider',
			'disackarider' => 'Disackarider',
			'sackaros' => 'Sackaros',
			'fullkorn_totalt' => 'Fullkorn Totalt',
			'summa_mattade_fettsyror' => 'Summa Mattade Fettsyror',
			'summa_enkelomattade_fettsyror' => 'Summa Enkelomattade Fettsyror',
			'summa_fleromattade_fettsyror' => 'Summa Fleromattade Fettsyror',
			'fettsyra' => 'Fettsyra',
			'ePA' => 'E Pa',
			'dPA' => 'D Pa',
			'dHA' => 'D Ha',
			'summa_transfettsyror' => 'Summa Transfettsyror',
			'kolesterol' => 'Kolesterol',
			'retinolekvivalenter' => 'Retinolekvivalenter',
			'retinol' => 'Retinol',
			'vitamin_D' => 'Vitamin D',
			'vitamin_E' => 'Vitamin E',
			'vitamin_K' => 'Vitamin K',
			'tiamin' => 'Tiamin',
			'riboflavin' => 'Riboflavin',
			'vitamin_C' => 'Vitamin C',
			'niacin' => 'Niacin',
			'niacinekvivalenter' => 'Niacinekvivalenter',
			'vitamin_B6' => 'Vitamin B6',
			'vitamin_B12' => 'Vitamin B12',
			'fosfor' => 'Fosfor',
			'folat' => 'Folat',
			'jod' => 'Jod',
			'jarn' => 'Jarn',
			'kalcium' => 'Kalcium',
			'kalium' => 'Kalium',
			'magnesium' => 'Magnesium',
			'natrium' => 'Natrium',
			'selen' => 'Selen',
			'zink' => 'Zink',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('livsmedelsnamn',$this->livsmedelsnamn,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}